home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-06-24 | 14.0 KB | 468 lines | [TEXT/MPS ] |
- ;############################################################
- ;# #
- ;# File: CDev.aii #
- ;# Version: 3.0 #
- ;# Author: #
- ;# Copyright: (c) 1989-1990 by Apple Computer, Inc. #
- ;# Developer Technical Support Apple II Sample Code #
- ;# #
- ;# Description: This file contains the assembler needed #
- ;# by the Shell CDEV on the IIGS. #
- ;# #
- ;#----------------------------------------------------------#
- ;# #
- ;# Development History: #
- ;# #
- ;# Who Date The Modification #
- ;# --- -------- ---------------- #
- ;# #
- ;############################################################
-
- blanks off
- string asis
-
- include 'E16.CDev'
-
- ;############################################################
- ;# #
- ;# CDEV executable module #
- ;# #
- ;############################################################
-
- ; This routine is eventually linked and then placed into a CDev code resource. The only
- ; requirements are that this routine is at the beginning of the resource so if the CDev has
- ; any other routines they must follow this one. The CDev's resource fork is always opened
- ; when a call to the CDev is made. The CDev can also assume that the current port is set to
- ; the control panel window except in the boot message, where QuickDraw isn't even started,
- ; and in the About message, where it is the port of the help window. All normal managers
- ; will be started up for all calls except the boot call, which will only have miscTools and
- ; Resource Manager started.
-
- CDEV func
-
- import CDEVLIST ;address of list of pointers to controls
- import AboutCDEV1 ;pointer to about stuff
-
- save_dbr equ $01
- retAddr equ $02
- data2 equ $05
- data1 equ $09
- message equ $0D
- retCode equ $0F
-
- phb ;save DBR
- tsc ;get stack pointer
- phd ;save original direct page
- tcd ;make local direct page
-
- phk ;set DBR to PBR
- plb
-
- stz retCode ;initialize return code
- stz retCode+2
-
- lda message ;get message value
- cmp #RunCDEV+1 ;valid message number?
- bcc good_message ;yes...
- lda #reserved1 ;else put it in range
- good_message
- dec a ;fix for indexing
- asl a ;multiply by 2
- tax ;put into index register
- lda case_table,x ;get address of correct routine
- pha ;put on stack
- rts ;and do the 'rts' trick
-
- case_table
- dc.w Machine_msg-1 ;case MachineCDEV
- dc.w Boot_msg-1 ;case BootCDEV
- dc.w ShutDown_msg-1 ;case ShutDownCDEV
- dc.w Init_msg-1 ;case InitCDEV
- dc.w Close_msg-1 ;case CloseCDEV
- dc.w Events_msg-1 ;case EventsCDEV
- dc.w Create_msg-1 ;case CreateCDEV
- dc.w About_msg-1 ;case AboutCDEV
- dc.w Rect_msg-1 ;case RectCDEV
- dc.w Hit_msg-1 ;case HitCDEV
- dc.w Run_msg-1 ;case RunCDEV
- dc.w null_msg-1 ;case reserved1 through NeverUsed2
-
- ;----------------------------------------------------------------------------------------------------
- ; If the wantBoot flag is set, this routine will be called during the startup sequence. The
- ; control panel takes care of drawing the "boot" icon. When this call is made, the machine
- ; state is bad at best. QuickDraw is not even started up. The parameters to this call are
- ; undefined.
-
- Boot_msg
- bra exit
-
- ;----------------------------------------------------------------------------------------------------
- ; This is called if the wantMachine bit is set in the CDev flaags. It enables the CDev to do
- ; further checking to see if it makes sense for the CDev to be visible to the user or not.
- ; For instance, if the CDev controls a setting for some hardware, we could check to see if
- ; the hardware is really connected. The parameters are undefined for this call and the result
- ; is passed back as the function result. 0 = don't show this cdev, <>0 = show this CDev.
- ; The control panel will do some machine checking even before calling this routine by checking
- ; the ROM version number against the machine field of the CDev flags resource.
-
- Machine_msg
- bra exit
-
- ;----------------------------------------------------------------------------------------------------
- ; If the wantCreate bit is set, this message is called with the control panel's window ptr
- ; passed in data1. The cdev must create any controls it has during this call. The CDEV's
- ; resource fork is open during this call so resource manager calls can be made. All controls
- ; rectangles MUST be relative to 0,0. The control panel handles offsetting controls
- ; to the proper place in the window. Initialization of the controls needs to be done in
- ; the InitCDEV call. Just create the controls in this call.
-
- Create_msg
- jsr do_Create ;go create the controls
- bra exit ;then return to caller
-
- ;----------------------------------------------------------------------------------------------------
- ; If the wantInit flag is set, then this message is passed with data1 = the control panel's
- ; window ptr. By this time the CreateCDEV call will have been made and thus the controls
- ; used by the CDEV created. This call enables the CDEV to initialize the controls before
- ; they are displayed.
-
- Init_msg
- jsr do_Init
- bra exit
-
- ;----------------------------------------------------------------------------------------------------
- ; If the wantAbout bit is set in the CDEV flags, this call is made when the user selects help.
- ; Data1 = window ptr to the help window. The control panel automatically handles the icon,
- ; author, and version # display.
-
- About_msg
- jsr do_About
- bra exit
-
- ;----------------------------------------------------------------------------------------------------
- ; If a CDEV has a different size data rectangle depending on some state, like the printer &
- ; modem port cdev's, then you can get a chance to tell the control panel this by setting the
- ; wantRect bit in the CDEV flags. In this call, data1 is a ptr to the rect and can be
- ; directly modified by the CDEV.
-
- Rect_msg
- bra exit
-
- ;----------------------------------------------------------------------------------------------------
- ; If the wantEvents bit is set, the control panel will call this routine with data1 = ptr to
- ; the event record. This allows the cdev to intercept and even *gasp* change the event record
- ; before it is handled by the control panel.
-
- Events_msg
- bra exit
-
- ;----------------------------------------------------------------------------------------------------
- ; If the CDEV wants to know when a control has been "hit", it can set the wantHit bit in the
- ; CDEV flags. When called, data1 = Hdl to Ctl Hit & data2 = Ctl ID of hit control. This message
- ; allows the CDEV to perform actions based on the control that was selected by the user.
-
- Hit_msg
- jsr do_Hit
- bra exit
-
- ;----------------------------------------------------------------------------------------------------
- ; This message is called if the "wantRun" bit is set in the CDEV flags. It enables CDEVs like
- ; time to update the display. It is called every 60th of a second - every time the DARun call
- ; is issued to the control panel. -no parameters are passed to this routine.
-
- Run_msg
- bra exit
-
- ;----------------------------------------------------------------------------------------------------
- ; The CloseCDEV message is passed if the wantClose bit is set in the CDEV flags and the control
- ; panel is closing or when the user selects another CDEV. During this call data1 = windowPtr.
- ; In general, CDEVs can do any memory disposal and saving of settings during this call. The
- ; disposal of the CDEV's controls is handled automatically by the Control Panel.
-
- Close_msg
- bra exit
-
- ;----------------------------------------------------------------------------------------------------
- ; If the wantShutDown bit is set in the CDEV flags resource then this routine is called when
- ; the user either disables the CDEV or *someday* when the machine is being turned off. It
- ; gives the CDEV a chance to turn itself off (or any hardware or software it controls).
- ; The parameters are undefined in this call.
-
- ShutDown_msg
- bra exit
-
- ;----------------------------------------------------------------------------------------------------
- ; This label is here to handle any message values that are out of range.
-
- null_msg
-
- ;----------------------------------------------------------------------------------------------------
-
- exit
- lda save_dbr ;get saved DBR and low byte of return address
- sta data1+2 ;move up in stack frame
- lda retAddr+1 ;get high word of return address
- sta message ;move it up too
- pld ;restore original direct page
- tsc ;remove parms from stack
- clc
- adc #10
- tcs
- plb ;restore original DBR
- rtl ;and return to control panel shell
-
- ;****************************************************************************************************
- ; do_Create - creates the popup controls
-
- do_Create
- pha ;make room on stack for returned control handle
- pha
- pei data1+2 ;put window pointer on stack
- pei data1
- pea 3 ;referenceDesc = pointer to list of pointers
- pea CDEVLIST>>16 ;put address of pointer on stack
- pea CDEVLIST
- ldx #$3110 ;NewControl2 call
- jsl $e10000
- pla ;remove returned handle
- pla
- rts
-
- ;****************************************************************************************************
- ; do_Init - sets the initial values of the popup controls
-
- do_Init
- pea 1 ;put current value of control on stack (for SetCtlValue)
-
- pha ;space for returned result
- pha
- pei data1+2 ;put window pointer on stack
- pei data1
- pea 0
- pea 1 ;control ID
- ldx #$3010 ;GetCtlHandleFromID call
- jsl $e10000
-
- ldx #$1910 ;SetCtlValue call
- jsl $e10000
-
- pea 1 ;put current value of control on stack (for SetCtlValue)
-
- pha ;space for returned result
- pha
- pei data1+2 ;put window pointer on stack
- pei data1
- pea 0
- pea 2 ;control ID
- ldx #$3010 ;GetCtlHandleFromID call
- jsl $e10000
-
- ldx #$1910 ;SetCtlValue call
- jsl $e10000
-
- pea 1 ;put current value of control on stack (for SetCtlValue)
-
- pha ;space for returned result
- pha
- pei data1+2 ;put window pointer on stack
- pei data1
- pea 0
- pea 3 ;control ID
- ldx #$3010 ;GetCtlHandleFromID call
- jsl $e10000
-
- ldx #$1910 ;SetCtlValue call
- jsl $e10000
-
- rts
-
- ;****************************************************************************************************
- ; do_About - creates the About static text control
-
- do_About
- pha ;space for returned handle
- pha
- pei data1+2 ;put window pointer on stack
- pei data1
- pea 0 ;referenceDesc = pointer to single control
- pea ABOUTCDEV1>>16 ;put pointer to about stuff on stack
- pea ABOUTCDEV1
- ldx #$3110 ;NewControl2 call
- jsl $e10000
- pla ;remove returned handle
- pla
- rts
-
- ;****************************************************************************************************
- ; do_Hit - handles a control 'hit'
-
- do_Hit
- lda data2 ;get Control ID
- cmp #3 ;is it three?
- bcc @not_three ;no...
- pha ;else save value
- ldx #$2c03 ;SysBeep call
- jsl $e10000
- pla ;retrieve ctl id
- @not_three
- cmp #2 ;two?
- bcc @not_two
- pha ;save value
- ldx #$2c03 ;SysBeep
- jsl $e10000
- pla
- @not_two
- cmp #1 ;one?
- bcc @not_one
- ldx #$2c03
- jsl $e10000
- @not_one
- rts
-
- endf
-
- ;############################################################
- ;# #
- ;# CDEV Control #1 #
- ;# #
- ;############################################################
-
- CDEV1 proc
-
- dc.w 9
- dc.l 1
- dc.w 2,5,14,195
- dc.l $87000000
- dc.w $0040
- dc.w $1004
- dc.l 0
- dc.w 76
- dc.l CDEV1Menu
- dc.w 1
-
- CDEV1Menu
- dc.b '>> Item 1:\H'
- dc.w 1
- dc.b $0d
- dc.b '== Impressive!\H'
- dc.w 1
- dc.b $0d
- dc.b '== Elegant!\H'
- dc.w 2
- dc.b $0d
- dc.b '== Amazing!\H'
- dc.w 3
- dc.b $0d
- dc.b '== Stupendous!\H'
- dc.w 4
- dc.b $0d
- dc.b '.'
- endp
-
- ;############################################################
- ;# #
- ;# CDEV Control #2 #
- ;# #
- ;############################################################
-
- CDEV2 proc
- dc.w 9
- dc.l 2
- dc.w 17,5,29,195
- dc.l $87000000
- dc.w $0040
- dc.w $1004
- dc.l 0
- dc.w 80
- dc.l CDEV2Menu
- dc.w 1
-
- CDEV2Menu
- dc.b '>> Item 2:\H'
- dc.w 2
- dc.b $0d
- dc.b '== Wow!\H'
- dc.w 1
- dc.b $0d
- dc.b '== Golly!\H'
- dc.w 2
- dc.b $0d
- dc.b '== Holy Cow!\H'
- dc.w 3
- dc.b $0d
- dc.b '.'
- endp
-
- ;############################################################
- ;# #
- ;# CDEV Control #3 #
- ;# #
- ;############################################################
-
- CDEV3 proc
- dc.w 9
- dc.l 3
- dc.w 32,5,44,195
- dc.l $87000000
- dc.w $0040
- dc.w $1004
- dc.l 0
- dc.w 80
- dc.l CDEV3Menu
- dc.w 1
-
- CDEV3Menu
- dc.b '>> Item 3:\H'
- dc.w 3
- dc.b 13
- dc.b '== Too Hip!\H'
- dc.w 1
- dc.b 13
- dc.b '== That''s All!\H'
- dc.w 2
- dc.b 13
- dc.b '.'
- endp
-
- ;############################################################
- ;# #
- ;# CDEV Control Lists #
- ;# #
- ;############################################################
-
- CDEVLIST proc
-
- dc.l CDEV1
- dc.l CDEV2
- dc.l CDEV3
- dc.l 0
-
- endp
-
- ;############################################################
- ;# #
- ;# CDEV 'About' control #
- ;# #
- ;############################################################
-
- AboutCDEV1 proc
-
- dc.w 8
- dc.l 1
- dc.w 38,5,138,280
- dc.l $81000000
- dc.w $0000
- dc.w $1000
- dc.l 0
- dc.l theText
- dc.w endText-theText
-
- string asis
- theText
- dc.b 'This CDEV shows how easy it is to create a CDEV on the AppleIIgs.'
- endText
- string pascal
-
- endp
-
- end